package com.xiaoma.tpo.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.xiaoma.tpo.baseDao.BaseDaoImpl;
import com.xiaoma.tpo.baseDao.DefaultRowMapper;
import com.xiaoma.tpo.domain.Test;

@Repository
public class TestDao extends BaseDaoImpl<Test>{

    public void insert1() {
        jdbcTemplate.update("insert into test2(name, age) values('bob',33)");
    }
    
    @SuppressWarnings("unchecked")
    public List<Test> findU(int id) {
//        String sql = "select * from test where age = ?  order by id desc";
        String sql = "select * from test where age = ? union (select * from test where age >= ?) order by id desc";
        List<?> items = jdbcTemplate.query(sql, new DefaultRowMapper(Test.class, getNameHandler()), id, id);
        return (List<Test>)items;
    }
    
}
